package output.store.view.base;

public class Frame
{
	public double time;
	
	public String str;
	
	public int particleCount;
	public double[][] pos;
	public double[][] phaseVolume;
	
	public Frame(String _str)
	{
		str = _str;
		
		FrameLoad frameLoad = new FrameLoad(this);
		frameLoad.start();
	}
}

class FrameLoad extends Thread
{
	private Frame frame;
	
	public FrameLoad(Frame _frame)
	{
		frame = _frame;
	}
	
	/*
	0	time
	1	1, 2, 3...
	2	pos[0]
	3	pos[1]
	4	pos[2]
	5	spd[0]
	6	spd[1]
	7	spd[2]
	8	volume[0]
	9	volume[1]
	*/
	public void run()
	{
		String[] objs = frame.str.split("\n");
		frame.time = Double.parseDouble(objs[0]);
		
		int particleCount = objs[1].split(", ").length;
		
		String[] pos0 = objs[2].split(", ");
		String[] pos1 = objs[3].split(", ");
		String[] pos2 = objs[4].split(", ");
		String[] volume0 = objs[8].split(", ");
		String[] volume1 = objs[9].split(", ");
		
		double[][] _pos = new double[particleCount][3];
		double[][] _phaseVolume = new double[particleCount][2];
		for(int i = 0; i < particleCount; i++)
		{
			_pos[i][0] = Double.parseDouble(pos0[i]);
			_pos[i][1] = Double.parseDouble(pos1[i]);
			_pos[i][2] = Double.parseDouble(pos2[i]);
			
			_phaseVolume[i][0] = Double.parseDouble(volume0[i]);
			_phaseVolume[i][1] = Double.parseDouble(volume1[i]);
		}
		frame.particleCount = particleCount;
		frame.pos = _pos;
		frame.phaseVolume = _phaseVolume;
		
		frame.str=null;
	}
}